#include <stdio.h>
int main()
{
	int bjt;
	int utc;
	scanf("%d",&bjt);
	
	if((0<=bjt)&& (bjt<=2359)){
		if(bjt>=800){
			utc=bjt-800;
			printf("%d",utc);
		}
		else{
			utc=bjt+2400-800;
			printf("%d",utc);
		}
	}
}
